package love.yuanmengrobot.springmvcdemo2.mapper;

import love.yuanmengrobot.springmvcdemo2.pojo.SysRole;
import love.yuanmengrobot.springmvcdemo2.pojo.SysUser;
import love.yuanmengrobot.springmvcdemo2.vo.UserVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {
    int deleteByPrimaryKey(Integer userid);

    int insert(SysUser record);

    int insertSelective(SysUser record);

    SysUser selectByPrimaryKey(Integer userid);
    SysUser selectByLoginnameAndUserid(String loginname);
    int updateByPrimaryKeySelective(SysUser record);

    int updateByPrimaryKey(SysUser record);
    /**
     * 登录
     */
    SysUser login(UserVo userVo);
    //查询管理员和办公人员的姓名和邮箱
    List<SysUser>  queryNameAndEmail(SysUser user);



    //查询所有用户 以及模糊查询
    List<SysUser> queryAllUser(SysUser user);

//查询所有管理员以及模糊查询
    List<SysUser> queryAllAdministrators(SysUser user);


    //查询当前用户拥有的角色
    List<SysRole> queryUserHaveRole(@Param("uid") Integer id);
    //根据用户的id删除对应的角色
    void deleteRoleAndUserByUid(Integer uid);
    //保存用户分配的角色
    void saveSelectRole(@Param("uid") Integer uid, @Param("rid") Integer id);
}